#
# Find the contiguous subarray within an array (containing at least one number) 
# which has the largest product.
#

# @author: timlentse(tinglenxan@gmail.com)
# @Date: 2014-11-19

    # @param A, a list of integers
    # @return an integer
def maxProduct(Arr):
    if not Arr:
        return
    else:
        currentProduct1 = 1
        currentProduct2 = 1
        maxProduct = Arr[0]
        for x in Arr:
            if currentProduct1==0:
                currentProduct1 = x
                currentProduct2 = 1
            elif currentProduct1*currentProduct2>0:
                currentProduct2 = currentProduct1*currentProduct2
                currentProduct1 = x
            else:
                currentProduct1 *= x 
            if 
            maxProduct = currentProduct2 if maxProduct < currentProduct2 else maxProduct
    return maxProduct
testArr = [2,3,-2,-4,5]
#print maxProduct(testArr)
            